<title>ReaLua Window</title>

<p style="text-align: center; font-size: small">
<a href="index.html">Return to Index</a></p>

<h1 style="text-align: center;">The ReaLua Window</h1>

<p>Open the ReaLua Window from Reaper with
<code>ALT-0</code> (alt zero).  Close the
ReaLua Window with the close box, <code>ALT-F4</code>,
or the <code>exit()</code> global function.  You can open it from
a script with the <code>window()</code> global function.  It should
behave like a normal Windows window.</p>

<p>Only one ReaLua Window can be open.  Pressing
<code>ALT-0</code> from Reaper again should front the
existing ReaLua Window or create a new one.</p>

<p>The ReaLua Window has three parts:  Input, Output, and Prompt.</p>

<p><img src="window.jpg" alt="ReaLua Window"></img></p>

<h2>The Output Area</h2>

<p>The large white top area, which displays the
Lua version and copyright information upon
starting ReaLua, contains all printed output
from Lua, as well as your entered text.</p>

<p>You can clear this area with the <code>cls()</code>
function in the global namespace.</p>

<p>The area will hold between 500 and 600 lines before
throwing the top hundred away.  <code>cls()</code>
throws them all away.</p>

<p>Text in this area can be selected and copied, and
then pasted into the Input area or your favorite editor.
The <code>dump()</code> function will dump the contents
of the Output Area to a text file.</p>

<h2>The Input Area</h2>

<p>The smaller white section at the bottom is where you type
and edit your Lua.  To send the contents of this section to
Lua, press <code>CTRL-Enter</code> (control-Enter).<p>

<p>When you press the <code>Enter</code> key without
the <code>CTRL</code> (control) key, a new line is opened
in the Input area, for multi-line Lua fragments.</p>

<p>To edit larger fragments, use a real editor - I recommend
<a href="http://www.scintilla.org/SciTE.html">SciTE</a> but
Windows Notepad will do.</p>

<p>You can paste, cut, select and all that standard Windows
stuff in the Input area until you are satisfied, then press
<code>CTRL-Enter</code> to send it to Lua (and the Output area).</p>

<p><img src="action.jpg" alt="Action Shot"></img></p>

<h2>The Prompt Area</h2>

<p>The Prompt area simply displays the default caret
prompts, or the contents of the <code>_PROMPT</code>
and <code>_PROMPT2</code> variables if they are set.</p>

<p>If you set the prompt variables to long strings, the output will
be truncated.</p>

<h1>Standard I/O, <code>print()</code> and <code>input()</code></h1>

<p>The Lua <code>print(...)</code> function has been
redefined to send its output to the Output section.
Unlimited amounts of text can be sent with the
<code>print()</code> function, but display is
not guaranteed.</p>

<p>Standard output to the Output area with <code>io.write()</code> works
<b>for small amounts of text only</b>, a few lines at a time.</p>

<p>If you send too much with <code>io.write()</code>, the pipe will get clogged and
you must kill Reaper with a task manager.</p>

<p><a href="http://lua-users.org/wiki/NonBlockingLuaExecution">Non-blocking Lua</a>
is currently a philosophical problem, and may be beyond the scope
of ReaLua.</p>

<p>The rule is:  if you are sending output to the Output area,
use <code>print()</code>; if you are doing file I/O, use the
<code>io</code> library.</p>

<p>Standard input is not hooked up and does nothing (I hope).</p>

<p>Use the <code>input( <i>[prompt]</i>, <i>[default]</i>, ...)</code>
function to get a line of input from the user.</p>

<p><img src="input.jpg" alt="input"></img></p>

<h2>File I/O</h2>

<p>The file I/O of the <code>io</code> library works as normal.</p>

<p style="text-align: center; font-size: small">
<a href="index.html">Return to Index</a></p>
